package com.lxq.quicklearning.activities

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.appcompat.app.AlertDialog
import com.android.volley.Request
import com.android.volley.RequestQueue
import com.android.volley.Response
import com.android.volley.toolbox.JsonObjectRequest
import com.android.volley.toolbox.Volley
import com.lxq.quicklearning.R
import com.lxq.quicklearning.activities.config.CommonInfo

class LauncherActivity : AppCompatActivity() {
    private lateinit var volleyQueue: RequestQueue
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        volleyQueue = Volley.newRequestQueue(this)
        setContentView(R.layout.activity_launcher)
        getLauncherNotice()

    }

    private fun getLauncherNotice() {
        var api = CommonInfo.getHttpPrefix() + "notice/index/1"
        //var param = JSONObject()
        var httpRequest = JsonObjectRequest(Request.Method.GET,api, null,
            Response.Listener {
                val alert=AlertDialog.Builder(this)
                alert.setTitle(it.optString("noticeTitle"))
                alert.setMessage(it.optString("noticeContent"))
                alert.show()
            }, Response.ErrorListener {
                val alert=AlertDialog.Builder(this)
                alert.setMessage("网络错误："+it.message)
                alert.show()
            })
        volleyQueue.add(httpRequest)
    }
}